package com.zt.bigdata.vertx.config

import com.zt.bigdata.vertx.ResponseContent
import io.vertx.core.Vertx
import io.vertx.redis.RedisClient


/**
  *
  */
object Container {
  private val redisClients = new Array[RedisClient](16)

  private var responseContent: ResponseContent = _

  private var vertx: Vertx = _

  def getVertx: Vertx = {
    vertx
  }

  def setVertx(vertx: Vertx): Unit = {
    Container.vertx = vertx
  }

  def getRedisClient: RedisClient = {
    getRedisClient(0)
  }

  def getRedisClient(index: Int): RedisClient = {
    if (index < 0 || index > 15) {
      throw new NullPointerException()
    }
    redisClients(index)
  }

  def addRedisClient(index: Int, client: RedisClient): Unit = {
    if (index < 0 || index > 15) {
      throw new NullPointerException()
    }
    redisClients(index) = client
  }

  def getResponseContent: ResponseContent = {
    responseContent
  }

  def setResponseContent(responseContent: ResponseContent): Unit = {
    Container.responseContent = responseContent
  }


}
